<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

$cakeDescription = __d('cake_dev', 'Maybe Face');
?>
<!DOCTYPE html>
<html>
<head>
	<?php echo $this->Html->charset(); ?>
	<title>
		<?php echo $title_for_layout; ?>
	</title>
	<?php
		echo $this->Html->meta('icon');

		echo $this->fetch('meta');
		
		// CSS
		echo $this->Html->css('bootstrap');
		echo $this->Html->css('maybeface');
		echo $this->fetch('css');
		
		// Script
		echo $this->Html->script('jquery-1.10.1.min');
		echo $this->Html->script('jquery-migrate-1.2.1.min');
		echo $this->Html->script('bootstrap.min');
		echo $this->fetch('script');
	?>
</head>
<body>
	<?php
		$userInfo = $this->Session->read('Auth');
		
		$isLogged = isset($userInfo['User']['id']) ? true : false;
		
		$userName = isset($userInfo['User']['id']) ? $userInfo['User']['user_name'] : 'Guest';
	?>
	
	<div class="navbar navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<?php 
					echo $this->Html->link(
						$cakeDescription, 
						array('controller' => 'home', 'action' => 'index'),
						array('class' => 'blue-text brand', 'onclick' => 'return false;')
					); 
				?>
				
				<div class="nav-collapse collapse">
					<ul class="nav">
						<li><?php echo $this->Html->link('Home', array('controller' => 'home', 'action' => 'index'));?></li>
					</ul>
					
					<?php if ($isLogged) {?>
						<ul class="nav pull-right">
							<li class="dropdown">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown" onclick="return false;">
									<?php echo $userName;?>
									<b class="caret"></b>
								</a>
								
								<ul class="dropdown-menu">
									<li><?php echo $this->Html->link('Manage Profile', array('controller' => 'profiles', 'action' => 'index'));?></li>
							    	<li class="divider"></li>
							    	<li><?php echo $this->Html->link('Logout', array('controller' => 'users', 'action' => 'logout'))?></li>
								</ul>
							</li>
						</ul>
					<?php }?>
				</div>
			</div>
		</div>
	</div>
		
	<div id="container" class="container">
			<legend><?php echo isset($title_for_content) ? $title_for_content : $cakeDescription;?></legend>

			<?php echo $this->Session->flash(); ?>

			<?php echo $this->fetch('content'); ?>
	</div>
	<?php //echo $this->element('sql_dump'); ?>
</body>
</html>
